<?php
include "conn.php";//引入数据库连接

//1.将注册数据提交到数据库
if(isset($_POST['submit'])){//判断是否点击了submit按钮
    //获取表单的值
    $tel = $_POST['tel'];
    $pass = sha1($_POST['password']);
    $conn->query("insert registry values(null,'$tel','$pass',NOW())");
    //跳转到登录页面
    header('location:http://10.31.157.19/myule/src/login.html');
}


//2.用户名重名检测
if(isset($_POST['tell'])){
    $tel = $_POST['tell'];
    $result = $conn->query("select * from registry where tel='$tel'");//检测当前的手机号是否存在。
    if($result->fetch_assoc()){
        echo 1;
    }else{
        echo 2;
    }
}